package com.yixun.qfbao.hander;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.qiaofang.common.util.StringUtil;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.model.dto.CompanyDto;
import com.yixun.qfbao.service.CompanyService;
import com.yixun.qfbao.vo.UpdateCompanyAbbreviationReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;

/**
 * @author zilong.liu
 * @date 2020-10-26
 *
 * desc:
 *     	更新公司缩写
 */
@Service("updateComapnyAbbreviationHander")
public class UpdateCompanyAbbreviationHander extends CommonAbstractHander{

	@Autowired
	CompanyService companyService;
	
	@SuppressWarnings("rawtypes")
	@Override
	public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
		UpdateCompanyAbbreviationReqVo reqVo = (UpdateCompanyAbbreviationReqVo) reqDto;
		String companyAbbreviation = reqVo.getParams().getCompanyAbbreviation();
		BaseResponseDTO res = new BaseResponseDTO();
		if(StringUtil.isEmpty(companyAbbreviation)) {
			res.setResult(ResultEnum.FAIL.getNo());
			res.setErrorMsg("公司简称不能为空");
			return res;
		}
		CompanyDto entity = new CompanyDto();
		entity.setCompanyAbbreviation(companyAbbreviation);
		entity.setCompanyUuid(reqVo.getParams().getCompanyUuid());
		companyService.updateByComapnyUuid(entity);
		res.setResult(ResultEnum.SUCCESS.getNo());
		return res;
	}

}
